<?php
include_once "../../../../common.php";

?>
<b>Nieuwe <?php
if(isset($_GET['id']) && is_numeric($_GET['id']) && !empty($_GET['id']))
{
	// id is sub catogorie (empty == root catogorie
	$query = "SELECT Naam FROM ProductCatogorien WHERE ID = '".str_replace("'","",$_GET['id'])."'";
	$result = $_MySQL->runQuery($query);
	$row = mysql_fetch_assoc($result);
	?>subcatogorie onder 
	<?php
	echo $row['Naam'];
}
else
{
	?>hoofd catogorie<?php
}
?></b><br />
<table width="100%">
	<tr>
		<td>
			Naam
		</td>
		<td>:</td>
		<td>
			<input type="text" id="nieuweCatogorieNaam" value="" />
		</td>
	</tr>
	<tr>
		<td colspan="3" style="height:10px;">
		</td>
	</tr>
	<tr>
		<td colspan="3" align="right">
			<input type="button" value=" Opslaan " onClick="javascript: addCatogorie();" />
		</td>
	</tr>
</table>
<script>
	function addCatogorie()
	{
		var url = 'factory/saveCatogorie.php';
		var naam = $('#nieuweCatogorieNaam').val();
		$.post(
			url, 
			{
				naam: naam
				<?php
				if(isset($_GET['id']) && is_numeric($_GET['id']) && !empty($_GET['id']))
				{
					?>
					, id: '<?=$_GET['id'];?>'
					<?php
				}
				?>
			}, 
			function(data){
				if(data == 'succes')
				{
					// close popup
				}
				else
				{
					alert(data);
				}
			}
		);
	}
</script>